package com.ms.game.itembox.db;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.ms.game.itembox.ItemStatus;
import com.xpec.c4.db.model.basic.BasicGameModel;


@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name = AccountItemModel.TABLENAME)
@org.hibernate.annotations.Table(
		appliesTo = AccountItemModel.TABLENAME, indexes = {
				@org.hibernate.annotations.Index(name = "IDX_SN", columnNames = { "sn" }),
				@org.hibernate.annotations.Index(name = "IDX_OWNERACCOUNTID", columnNames = { "ownerAccountId" }),
				@org.hibernate.annotations.Index(name = "IDX_STATUS", columnNames = { "status" })
		})
public class AccountItemModel extends BasicGameModel{
	
	public final static String TABLENAME = "account_items";
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4340328221277199046L;
	
	public AccountItemModel() {
		eventTime = Calendar.getInstance();
		eventDate = eventTime.getTime();
	}
	
	/**
	 * 拿到禮包的時間
	 */
	private Calendar eventTime; 
	
	/**
	 * 為增進統計計算效率,新增此欄位(因為統計常常需要以日為單位計算數量)
	 */
	private Date eventDate;
	
	/**
	 * 道具序號
	 */
	private String sn;
	
	/**
	 * 數據表 {@link ItemBoxModel} 中對應的 key
	 */
	private String itemId;
	
	/**
	 * 這個道具的 accountId
	 */
	private String ownerAccountId;
	
	/**
	 * 是否有過期時間
	 */
	private boolean hasExpireTime;
	
	/**
	 * 過期時間
	 */
	private long expireTime;
	
	/**
	 * 堆疊數量
	 */
	private int count;
	
	/**
	 * 狀態
	 */
	private int status;
	
	/**
	 * 狀態說明 
	 */
	private ItemStatus statusDesc;

	public Calendar getEventTime() {
		return eventTime;
	}

	public void setEventTime(Calendar eventTime) {
		this.eventTime = eventTime;
		this.eventDate = eventTime == null? null : eventTime.getTime();
	}

	@Temporal(TemporalType.DATE)
	public Date getEventDate() {
		return eventDate;
	}

	public void setEventDate(Date eventDate) {
		this.eventDate = eventDate;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public String getOwnerAccountId() {
		return ownerAccountId;
	}

	public void setOwnerAccountId(String ownerAccountId) {
		this.ownerAccountId = ownerAccountId;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public boolean isHasExpireTime() {
		return hasExpireTime;
	}

	public void setHasExpireTime(boolean hasExpireTime) {
		this.hasExpireTime = hasExpireTime;
	}

	public long getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(long expireTime) {
		this.expireTime = expireTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Enumerated(EnumType.STRING)
	public ItemStatus getStatusDesc() {
		return statusDesc;
	}

	public void setStatusDesc(ItemStatus statusDesc) {
		this.statusDesc = statusDesc;
	}


	
}
